clear;
clc;

cd 'dir'
%%-------------------------------------------------------------------------
%%Part 1: Make Plots for Japanese Industrial Production Data
%%-------------------------------------------------------------------------


load jpn_data_hp.txt
indprod_hp = jpn_data_hp(79:97,9);
x=datenum(2004,1:111,1)';
y = datestr(x);
time = x(79:97);

%%Chart 1: Japanese Industrial Production
set(0,'DefaultAxesFontSize',12)
figure(1)
handlevector(1) = plot(time,indprod_hp(:,1),'k','LineWidth',2);
set(gca,'XTick',[734320 734504 734685 734869]);
set(gca,'XTickLabel',[734320 734504 734685 734869]);
datetick('x','mmm.yyyy','keepticks')
grid;
ylim([-.12 0.08])
set(gca,'YTick',[-0.12 -0.1 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08]);
set(gca,'YTickLabel',[-0.12 -0.1 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08]);
ylabel('Deviations from Trend (HP-Filtered)')
print(figure(1), '-dpng','-r600','jpn_indprod_hp.png');


%%-------------------------------------------------------------------------
%%Part 2: Make Plots for Trade
%%-------------------------------------------------------------------------

clear;

load usimp_data.txt
hpljpnimp = usimp_data(259:277,12);
hplrowimp = usimp_data(259:277,13);
x=datenum(2004,1:111,1)';
y = datestr(x);
time = x(79:97);

%%Plot 2b: U.S. Imports (HP-Filtered)
set(0,'DefaultAxesFontSize',12)
figure(2)
handlevector(1) = plot(time,hpljpnimp(:,1),'k','LineWidth',2);
hold on;
handlevector(2) = plot(time,hplrowimp(:,1),'Color',[0 0 0]+.4,'LineStyle','--','LineWidth',2);
set(gca,'XTick',[734320 734504 734685 734869]);
set(gca,'XTickLabel',[734320 734504 734685 734869]);
datetick('x','mmm.yyyy','keepticks')
grid;
ylim([-0.2 0.15])
ylabel('Deviations from Trend (HP-Filtered)')
legend(handlevector([1 2 ]),...
{'U.S. Imports from Japan','U.S. Imports from Rest of World'}, 'Location','NorthEast');
print(figure(2), '-dpng','-r600','usjpnimp_alt.png');



%%-------------------------------------------------------------------------
%%Part 3: Make Plots for U.S. Data
%%-------------------------------------------------------------------------
clear
load usagg_data.txt

hpldurable = usagg_data(295:313,8);
hplmanuf = usagg_data(295:313,10);
x=datenum(2004,1:111,1)';
time = x(79:97);


%%Plot 3: U.S. Industrial Production
set(0,'DefaultAxesFontSize',12)
figure(3)
handlevector(1) = plot(time,hpldurable(:,1),'k','LineWidth',2);
hold on;
handlevector(2) = plot(time,hplmanuf(:,1),'Color',[0 0 0]+.4,'LineStyle','--','LineWidth',2);
set(gca,'XTick',[734320 734504 734685 734869]);
set(gca,'XTickLabel',[734320 734504 734685 734869]);
datetick('x','mmm.yyyy','keepticks')
grid;
ylabel('Deviations from Trend (HP-Filtered)')
legend(handlevector([1 2 ]),...
{'U.S. Durable Goods Production','U.S. Manufacturing Production'}, 'Location','NorthEast');
print(figure(3), '-dpng','-r600','usindprod.png');
